$(function () {
    get()
})
function get() {
    $.ajax({
        menthod: "GET",
        url: "/my/userinfo",
       /*  headers: {
            Authorization: localStorage.getItem('token') || ''
        }, */ success: function (res) {
            if (res.code !== 0) {
                return layui.layer.msg('失败')
            }
            //调用render函数渲染用户头像
            render(res.data)
        }
    })
}
function render(user) {
    var name = user.nickname || user.username
    $('#welcome').html('欢迎&nbsp;&nbsp;' + name)
    if (user.user_pic !== null) {
        $('.layui-nav-img').attr('src', user.user_pic).show()
        $('.text-avatar').hide()
    } else {
        $('.layui-nav-img').hide()
        var wz = name[0].toUpperCase()
        $('.text-avatar').html(wz).show()
    }
}